Methods
(static) makeKeysGetter(keys) → {function}
- Source:
- Since:
- 0.1.0
Return a function expecting an object and returning an array of values corresponding to the provided keys.
Example
> getCoordinates = makeKeysGetter(['lng', 'lat']);
> getCoordinates({
name: 'London',
lat: 51.507222,
lng: -0.1275,
population: 8825000
});
[-0.1275, 51.507222]
Parameters:
Name | Type | Description |
---|---|---|
keys |
array | Array of keys |
Returns:
- Object -> Array
- Type
- function
(static) pickAndConcatValues(keys) → {function}
- Source:
- Since:
- 0.4.0
Return a function expecting an object and concatenating values in the provided list of keys.
Example
> getProducts = pickAndConcatValues(['food', 'beverage'])
> getProducts({
food: ['bread', 'cheese', 'ham'],
beverage: ['wine', 'water'],
id: 'area1',
value: 32.1,
})
['bread', 'cheese', 'ham', 'wine', 'water']
Parameters:
Name | Type | Description |
---|---|---|
keys |
array | Array of keys |
Returns:
- Object -> Array
- Type
- function